//
//  JianLiViewController.m
//  YaDiuDiu
//
//  Created by 欧洪飞 on 2017/8/24.
//  Copyright © 2017年 jy. All rights reserved.
//

#import "JianLiViewController.h"

#import "JianLiDetViewController.h"
#import "YCNXViewController.h"
@interface JianLiViewController ()
@property (weak, nonatomic) IBOutlet UITextField *textName;
@property (weak, nonatomic) IBOutlet UITextField *textCard;
@property (weak, nonatomic) IBOutlet UIButton *btnAgree;
@property (weak, nonatomic) IBOutlet UIImageView *imageViews;

@end

@implementation JianLiViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self showNav:@"简历查询"];
    _imageViews.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickYC)];
    [_imageViews addGestureRecognizer:tap];
    
}

- (void)clickYC{
    YCNXViewController *ycnx = [[YCNXViewController alloc] init];
    [self.navigationController pushViewController:ycnx animated:YES];
}

- (IBAction)clickAgree:(UIButton *)sender {
    if (sender.tag == 10) {
        [_btnAgree setImage:[UIImage imageNamed:@"勾-(1)"] forState:UIControlStateNormal];
        _btnAgree.tag = 20;
    }else{
        [_btnAgree setImage:[UIImage imageNamed:@"矩形-7"] forState:UIControlStateNormal];
        _btnAgree.tag = 10;
    }
}


- (IBAction)clickService:(id)sender {
    
}
//查询
- (IBAction)clickCX:(id)sender {
    if (_btnAgree.tag == 10) {
        [self showAlert:@"请先同意丫丢丢服务条款"];
        return;
    }
    [self loadData];
    
}

- (void)loadData{
    NSMutableDictionary *parmas = [NSMutableDictionary dictionary];
    [parmas setObject:_textName.text forKey:@"realname"];
    [parmas setObject:_textCard.text forKey:@"idcard"];
    
    NSString *url = [NSString stringWithFormat:@"%@/App/Credit/resume",urlHead];
    [[AFHTTPSessionManager manager] POST:url parameters:parmas success:^(NSURLSessionDataTask *task, id responseObject) {
        //NSLog(@"res:%@",responseObject);
        
        NSString *error = [NSString stringWithFormat:@"%li",[[responseObject objectForKey:@"error"] integerValue]];
        if ([error integerValue] == 200) {
            JianLiDetViewController *det = [[JianLiDetViewController alloc] init];
            det.dic = [responseObject objectForKey:@"result"];
            det.array = [[responseObject objectForKey:@"result"] objectForKey:@"work"];
            det.datas = [[responseObject objectForKey:@"result"] objectForKey:@"edu"];
            [self.navigationController pushViewController:det animated:YES];
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        NSLog(@"error:%@",error);
    }];
    
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [[UIApplication sharedApplication].keyWindow endEditing:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
